﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class UserControl_DanhSachSanPham : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DSSanPham ds = new DSSanPham();
            
                if (String.IsNullOrEmpty(Request.QueryString["Search"]))
                {
                    //int kt;
                    //kt = Convert.ToInt32(Request.QueryString["ThuongHieuID"]) + Convert.ToInt32(Request.QueryString["LoaiID"]) + Convert.ToInt32(Request.QueryString["ChucNangID"]);
                    DataTable dt = new DataTable();
                    dt = ds.getAll(Request.QueryString["ThuongHieuID"], Request.QueryString["LoaiID"], Request.QueryString["ChucNangID"],Request.QueryString["TuGia"],Request.QueryString["DenGia"]);
                    this.cpPagding.DataSource = dt.DefaultView;
                    this.cpPagding.BindToControl = this.DataList1;
                    this.DataList1.DataSource = this.cpPagding.DataSourcePaged;
                    //this.DataList1.DataSource = dt;
                    this.DataList1.DataBind();
                    if (dt.Rows.Count <= 0)
                    {
                        this.lblNull.Text = "Không có sản phẩm thỏa mãn yêu cầu tìm kiếm";
                    }
                }
                else
                {
                    DataTable dt = new DataTable();
                    dt = ds.search(Request.QueryString["Search"]);
                    this.cpPagding.DataSource = dt.DefaultView;
                    this.cpPagding.BindToControl = this.DataList1;
                    this.DataList1.DataSource = this.cpPagding.DataSourcePaged;
                    this.DataList1.DataBind();
                    if (dt.Rows.Count <= 0)
                    { 
                        this.lblNull.Text="Không có sản phẩm thỏa mãn yêu cầu tìm kiếm";
                    }
                }

               
            
            
        }
    }
}